<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>v-on</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>v-on</h1>
    <hr>
    <div id="app">
        本场得分:{{count}}
        <br>
        <button v-on:click="add">加分</button>
        <button v-on:click="del">减分</button>
        <br>
        <input type="text" v-on:keyup.enter="onEnter" v-model="secondCount">
    </div>
</body>
<script>
    var app = new Vue({
        el:"#app",
        data:{ 
            count:1,
            secondCount:5
        },
        methods:{
            add:function(){
                this.count++;
            },
            del:function(){
                this.count--;
                if(this.count<=0){
                    this.count=0
                }
            },
            onEnter:function(){
                this.count=this.count+parseInt(this.secondCount);
            }
        },
        watch:{
            
        }
    })
</script>
</html>